﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Data.Common;
using DataAccessClasses;

namespace BUSINESS_OBJECT
{
    class STAFF
    {
        iDAC DAC = DACFactory.GetDAC();
        private long _ID = -99;
        private long _CID = -99;
        private string _S_NAME = "";
        private string _S_ADDRESS = "";
        private string _S_CITY = "";
        private string _S_STATE = "";
        private long _S_PINCODE = -99;
        private long _S_PHONE_NO = -99;
        private string _S_EMAIL_ID = "";
        private string _S_JOIN_DATE = "1/1/1800";
        private string _S_DESIGNATION = "";
        private long _SALARY = -99;
        private bool _ISDELETED = false;

        public bool ISDELETED
        {
            get
            {
                return _ISDELETED;
            }
            set
            {
                _ISDELETED = value;
            }
        }
        public long ID 
        {
            get
            {
                return _ID;
            }
            set
            {
                _ID = value;
            }
        }
        public long CID
        {
            get
            {
                return _CID;
            }
            set
            {
                _CID = value;
            }
        }

        public string S_NAME
        {
            get
            {
                return _S_NAME;
            }
            set
            {
                _S_NAME = value;
            }
        }
        public string S_ADDRESS
        {
            get
            {
                return _S_ADDRESS;
            }
            set
            {
                _S_ADDRESS = value;
            }
        }
        public string S_CITY
        {
            get
            {
                return _S_CITY;
            }
            set
            {
                _S_CITY = value;
            }
        }
        public string S_STATE
        {
            get
            {
                return _S_STATE;
            }
            set
            {
                _S_STATE = value;
            }
        }
        public long S_PINCODE
        {
            get
            {
                return _S_PINCODE;
            }
            set
            {
                _S_PINCODE = value;
            }
        }
        public long S_PHONE_NO
        {
            get
            {
                return _S_PHONE_NO;
            }
            set
            {
                _S_PHONE_NO = value;
            }
        }
        public string S_EMAIL_ID
        {
            get
            {
                return _S_EMAIL_ID;
            }
            set
            {
                _S_EMAIL_ID = value;
            }
        }
        public string S_JOIN_DATE
        {
            get
            {
                return _S_JOIN_DATE;
            }
            set
            {
                _S_JOIN_DATE = value;
            }
        }
        public string S_DESIGNATION
        {
            get
            {
                return _S_DESIGNATION;
            }
            set
            {
                _S_DESIGNATION = value;
            }
        }
        public long SALARY
        {
            get
            {
                return _SALARY;
            }
            set
            {
                _SALARY = value;
            }
        }

        public long SaveRecords()
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@ID", ID, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@CID", CID, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@S_NAME", S_NAME, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@S_ADDRESS", S_ADDRESS, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@ S_CITY", S_CITY, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam5 = DAC.Parameter("@S_STATE", S_STATE, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam6 = DAC.Parameter("@S_PINCODE", S_PINCODE, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam7 = DAC.Parameter("@S_PHONE_NO", S_PHONE_NO, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam8 = DAC.Parameter("@S_EMAIL_ID", S_EMAIL_ID, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam9 = DAC.Parameter("@S_JOIN_DATE", S_JOIN_DATE, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam10 = DAC.Parameter("@ S_DESIGNATION", S_DESIGNATION, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam11 = DAC.Parameter("@SALARY", SALARY, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam12 = DAC.Parameter("@ISDELETED", ISDELETED, DbType.Boolean, ParameterDirection.Input);

                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3, dbparam4, dbparam5, dbparam6, dbparam7, dbparam8, dbparam9, dbparam10, dbparam11, dbparam12 };
                return DAC.Save("STAFF_SAVE", dbparamcall);
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return -99;
        }
        public DataTable GetRecords(long ID, long CID, string S_NAME, string S_ADDRESS, string S_CITY, string S_STATE, long S_PINCODE, long S_PHONE_NO, string S_EMAIL_ID, string S_JOIN_DATE, string S_DESIGNATION, long SALARY, bool ISDELETED, string PARAANDOR)
        {
            try
            {
                DbParameter dbparam0 = DAC.Parameter("@ID", ID, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam1 = DAC.Parameter("@CID", CID, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam2 = DAC.Parameter("@S_NAME", S_NAME, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam3 = DAC.Parameter("@S_ADDRESS", S_ADDRESS, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam4 = DAC.Parameter("@ S_CITY", S_CITY, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam5 = DAC.Parameter("@S_STATE", S_STATE, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam6 = DAC.Parameter("@S_PINCODE", S_PINCODE, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam7 = DAC.Parameter("@S_PHONE_NO", S_PHONE_NO, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam8 = DAC.Parameter("@S_EMAIL_ID", S_EMAIL_ID, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam9 = DAC.Parameter("@S_JOIN_DATE", S_JOIN_DATE, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam10 = DAC.Parameter("@ S_DESIGNATION", S_DESIGNATION, DbType.AnsiString, ParameterDirection.Input);
                DbParameter dbparam11 = DAC.Parameter("@SALARY", SALARY, DbType.Int64, ParameterDirection.Input);
                DbParameter dbparam12 = DAC.Parameter("@ISDELETED", ISDELETED, DbType.Boolean, ParameterDirection.Input);
                DbParameter dbparam13 = DAC.Parameter("@PARAANDOR", PARAANDOR, DbType.AnsiString, ParameterDirection.Input);


                DbParameter[] dbparamcall = new DbParameter[] { dbparam0, dbparam1, dbparam2, dbparam3, dbparam4, dbparam5, dbparam6, dbparam7, dbparam8, dbparam9, dbparam10, dbparam11, dbparam12, dbparam13};
                DataTable dt1 = DAC.Select("STAFF_GET", dbparamcall);
                return dt1;
            }
            catch (Exception ex)
            {
                long Result = -99;
            }
            return null;
        }
    }
}
